function isDate(value)
{
	var day = value.substring(0,2);
	var month = value.substring(3,5);
	var year = value.substring(6,10);
	
	if(isNaN(day)||isNaN(month)||isNaN(year))
		return false;
	if(day==0||month==0||year==0)
		return false;
	if(day==29&&month==2&&!((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))))
		return false;
	if(day>29&&month==2)
		return false;
	if(day==31 && (month==2||month==4||month==6||month==9||month==11))
		return false;
	if(day>31)
		return false;
	if(month>12)
		return false;
	
	return true;
}

function minDate(value1,value2)
{	
	var date1 = value1.substring(6,10) + "/" + value1.substring(3,5) + "/" + value1.substring(0,2);
	var date2 = value2.substring(6,10) + "/" + value2.substring(3,5) + "/" + value2.substring(0,2);
	
	if(date1<date2) return value1;
	return value2;
}

function insData(value)
{		
	var dat;
	var obj;
	var nxt;
	
	if(isEqual(value,"txtDataAcquisto"))
	{
		dat = document.frmInsert.txtDataAcquisto.value;
		obj = document.frmInsert.txtDataAcquisto;
		nxt = document.frmInsert.chkGaranzia;
	}
	else
	if(isEqual(value,"txtDataAttivazione"))
	{
		dat = document.frmInsert.txtDataAttivazione.value;
		obj = document.frmInsert.txtDataAttivazione;
		nxt = document.frmInsert.txtDataScadenza;
	}
	else
	if(isEqual(value,"txtDataScadenza"))
	{
		dat = document.frmInsert.txtDataScadenza.value;
		obj = document.frmInsert.txtDataScadenza;
		nxt = document.frmInsert.chkConforme;
	}
	
	
	if(dat.length==2||dat.length==5)
	{
		dat = dat + "/";
		obj.value=dat;
	}
	else if(dat.length==10)
	{
		obj.blur();
	}
}

function isEqual(string1, string2)
{
	string1=string1.toUpperCase();
	string2=string2.toUpperCase();
	if(string1.indexOf(string2,0)<0)
		{return false;}
	else
		{return true;}
}
